import {reactive} from 'vue'
import axios from 'axios'
//数据

export default function (){
    let doglist = reactive(
        ["https://images.dog.ceo/breeds/pembroke/n02113023_5050.jpg"]
    )
    
    //方法
    //axios有专门的错误拦截器，以后再学
    async function getDog(){
        try {
        let result = await axios.get('https://dog.ceo/api/breed/pembroke/images/random')
        doglist.push(result.data.message)
        } catch (error) {
        alert(error)
        }
    }
    //向外部提供东西
    return {doglist,getDog}
}